home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
3_7.lha
/
3_7
/
3_7c.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
538b
|
24 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ Count the characters within the string.
/ Version 3
/ Look in the first maxlen characters for a null
/ character. Return its position (the length of
/ the string), or maxlen if it is not found.
nt strnlen(const char *s, int maxlen)
if (!s)
return 0;
int savemaxlen = maxlen;
while (maxlen-- > 0)
if (*s++ == '\0')
return savemaxlen - maxlen - 1;
return savemaxlen;